Use the right package for doc test variables
authorAlex Crichton <alex@alexcrichton.com>
Tue, 7 Oct 2014 19:01:10 +0000 (12:01 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 7 Oct 2014 19:01:10 +0000 (12:01 -0700)
src/cargo/ops/cargo_test.rs
tests/test_cargo_test.rs

index 3a2b61fc337a5cfc3b1037111b1da50383ad007f..387b3275102642627614a63fba87089551f92d78 100644 (file)
@@ -15,7 +15,6 @@ pub fn run_tests(manifest_path: &Path,
                  test_args: &[String]) -> CargoResult<Option<ProcessError>> {
     let mut source = try!(PathSource::for_path(&manifest_path.dir_path()));
     try!(source.update());
-    let package = try!(source.get_root_package());
 
     let mut compile = try!(ops::compile(manifest_path, &mut options.compile_opts));
     if options.no_run { return Ok(None) }
@@ -27,7 +26,7 @@ pub fn run_tests(manifest_path: &Path,
             Some(path) => path,
             None => exe.clone(),
         };
-        let cmd = compile.process(exe, &package).args(test_args);
+        let cmd = compile.process(exe, &compile.package).args(test_args);
         try!(options.compile_opts.shell.concise(|shell| {
             shell.status("Running", to_display.display().to_string())
         }));
@@ -51,12 +50,12 @@ pub fn run_tests(manifest_path: &Path,
 
     for (lib, name) in libs {
         try!(options.compile_opts.shell.status("Doc-tests", name));
-        let mut p = compile.process("rustdoc", &package)
+        let mut p = compile.process("rustdoc", &compile.package)
                            .arg("--test").arg(lib)
                            .arg("--crate-name").arg(name)
                            .arg("-L").arg(&compile.root_output)
                            .arg("-L").arg(&compile.deps_output)
-                           .cwd(package.get_root());
+                           .cwd(compile.package.get_root());
 
         // FIXME(rust-lang/rust#16272): this should just always be passed.
         if test_args.len() > 0 {
index 0fd300518caeae7eebe64d6e7e8fe1f1c359b6b2..fd11bd361f10d11b55894ce2f088884b9153d83e 100644 (file)
@@ -1122,8 +1122,12 @@ test!(selective_testing_with_docs {
             name = "d1"
             version = "0.0.1"
             authors = []
+
+            [lib]
+            name = "d1"
+            path = "d1.rs"
         "#)
-        .file("d1/src/lib.rs", "");
+        .file("d1/d1.rs", "");
     p.build();
 
     assert_that(p.process(cargo_dir().join("cargo")).arg("test")